// ignore_for_file: must_be_immutable

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

import 'package:get/get.dart';

import '../../constants/color_constants.dart';
import '../my_text_view.dart';

/// 相机相册的选择
class AlbumDefaultSelectDialog extends StatelessWidget {
  bool isTypeVideo = false;
  VoidCallback? cancelAction;
  VoidCallback cameraAction;
  VoidCallback albumAction;

  AlbumDefaultSelectDialog({
    Key? key,
    required this.cameraAction,
    required this.albumAction,
    this.cancelAction,
    this.isTypeVideo = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final bgColor = hexToColor("#FAFFFFFF");
    const roundRadios = 10.0;

    return Container(
      margin: const EdgeInsets.only(left: 30, right: 30, bottom: 30),
      child: Column(
        //顶部标题
        mainAxisSize: MainAxisSize.min,
        children: [
          // 顶部的文本
          Container(
            width: double.infinity,
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: bgColor,
                borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(roundRadios),
                  topRight: Radius.circular(roundRadios),
                )),
            child: MyTextView(
              isTypeVideo ? "选择视频".tr : "选择图片".tr,
              paddingTop: 10,
              paddingBottom: 10,
              textColor: ColorConstants.black323843,
              fontSize: 12,
              isFontRegular: true,
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerItem,
            height: 0.5,
          ),

          InkWell(
            onTap: () {
              onCancel();
              cameraAction.call();
            },
            child: Container(
              width: double.infinity,
              alignment: Alignment.center,
              color: bgColor,
              child: MyTextView(
                "相机".tr,
                textColor: ColorConstants.blue1578fe,
                paddingTop: 15,
                paddingBottom: 15,
                fontSize: 16,
                isFontMedium: true,
              ),
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerItem,
            height: 0.5,
          ),

          InkWell(
            onTap: () {
              onCancel();
              albumAction.call();
            },
            child: Container(
              width: double.infinity,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  color: bgColor,
                  borderRadius: const BorderRadius.only(
                    bottomRight: Radius.circular(roundRadios),
                    bottomLeft: Radius.circular(roundRadios),
                  )),
              child: MyTextView(
                "相册".tr,
                textColor: ColorConstants.blue1578fe,
                fontSize: 16,
                paddingTop: 15,
                paddingBottom: 15,
                isFontMedium: true,
              ),
            ),
          ),

          // 分割线
          Container(
            color: ColorConstants.dividerA6,
            height: 0.5,
          ),

          // 取消按钮
          InkWell(
            onTap: () {
              onCancel();
              cancelAction?.call();
            },
            child: Container(
              margin: const EdgeInsets.only(top: 10),
              width: double.infinity,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                  color: bgColor,
                  borderRadius: const BorderRadius.all(Radius.circular(roundRadios))),
              child: MyTextView(
                "取消".tr,
                textColor: ColorConstants.blue1578fe,
                fontSize: 16,
                paddingTop: 15,
                paddingBottom: 15,
                isFontMedium: true,
              ),
            ),
          ),
        ],
      ),
    );
  }

  //取消弹框
  void onCancel() async {
    SmartDialog.dismiss();
  }
}
